<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta charset="UTF-8">
<title>Triple Buy Angel</title>
<link href="${pageContext.request.contextPath }/css/mystyle.css"
	rel="stylesheet">
</head>
<body>
	<div id="div1"></div>
	<div id="#container">
		<div id="header">
			<b id="fonts1">买买买小天使 Triple Buy Angel</b>
			<div id="login">
				<b id="fonts2"> <c:choose>
						<c:when test="${email != ''}">
							<b id="fonts2">Hello "${email }" <a
								href="${pageContext.request.contextPath }/ShowOrderListServlet"> <input type="button"
									value="OrderList" class="btn"></input>
							</a> <a href="${pageContext.request.contextPath }/IndexServlet"> <input type="button"
									value="Logout" class="btn"></input>
							</a>
							</b>
						</c:when>
						<c:otherwise>
							<form action="${pageContext.request.contextPath }/LoginServlet" method="post">
								E-mail<input type="text" name="email" value="${error}"></input>
								Password<input type="password" name="password""></input> <input
									type="submit" value="Login" class="btn" id="loginBtn"></input>
								<a href="${pageContext.request.contextPath }/jsp/register.jsp">
									<input type="button" value="Register" class="btn">
								</a>
							</form>
						</c:otherwise>
					</c:choose>
				</b>
			</div>
		</div>

		<div id="dishes">
			<c:forEach var="dish" items="${dishes}">
				<div id="nav">
					<table>
						<tr>
							<td><img
								src="${pageContext.request.contextPath }/images/${dish.img }.jpg"
								id="image">
								<p class="fonts3">Dish: ${dish.dname}</p>
								<p class="fonts3">Price: ${dish.price}</p>
								<button onclick="buy('${dish.dishId}', '${email}')" class="btn">Buy</button>
							</td>
						</tr>
					</table>
				</div>
			</c:forEach>
		</div>
		<div id="cartnav">
			<b class="fonts4">Shopping Cart</b>
			<table id="cart" class="fonts3">
				<c:forEach var="cart" items="${cart}">
					<c:choose>
						<c:when test="${cart.key == 'TotalPrice RMB:'}">
							<tr id="total">
								<td>TotalPrice RMB:</td>
								<td id="abc">${cart.value}</td>
							</tr>
							<c:set var="total" value="${cart.value}"></c:set>
						</c:when>
						<c:otherwise>
							<tr>
								<td>${cart.key}</td>
								<td><button onclick="mines('${cart.key}', '${email}')"
										class="btn">-</button></td>
								<td>${cart.value}</td>
								<td><button onclick="plus('${cart.key}', '${email}')"
										class="btn">+</button></td>
							</tr>
						</c:otherwise>
					</c:choose>
				</c:forEach>

			</table>
			
			<form action="${pageContext.request.contextPath }/CheckoutServlet" method="post">
				<p><input type="submit" value="CheckOut" class="btn"></input></p>
			</form>
		</div>

	</div>


</body>
<script src="${pageContext.request.contextPath }/js/addToCart.js"></script>
<script src="${pageContext.request.contextPath }/js/Map.js"></script>
<script src="${pageContext.request.contextPath }/js/plus.js"></script>
<script src="${pageContext.request.contextPath }/js/mines.js"></script>
</html>